package com.service.impl;

import com.dao.AdminDao;
import com.dto.DTO;
import com.dto.MessageEnum;
import com.entity.Admin;
import com.exception.CustomException;
import com.service.AdminService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;
import java.util.Random;

@Service("AdminService")
public class AdminServiceImpl implements AdminService {
    @Resource
    AdminDao adminDao;
    @Override
    public DTO<Admin> getAllAdmins() {
        List<Admin> admins = adminDao.getAllAdmins();
        MessageEnum messageEnum  = Optional.ofNullable(admins).isPresent()?MessageEnum.GETALLADMINSUCCESS:MessageEnum.GETALLADMINFAIL;
        return new DTO<Admin>(messageEnum.getCode(),messageEnum.getMessage(),admins);
    }
}
